#include <stdlib.h>
#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
//===========================================
int checkIfProcess()
//===========================================
{
   FILE  *in;
   char  line[128],key[24];
   int result=0;

   in = fopen("wd.result","r");
   if(in == NULL)
   {
   }
   else
   {
     while (fgets(line,sizeof line,in) != NULL)
     {
        printf("%s",line);
        //sscanf(line,"%s",key);
        if(strstr(line,"client_user") != NULL) result = 1;
     }
     fclose(in);
     system("rm -f wd.result");
   }
   if(result == 0)
   {
      printf("Process dead\n");
      system("sudo /home/pi/client_user_100_id_1234 &");
   }
   else
      printf("Process running...\n");
   return(result);
}
//===========================================
main()
{
  while(1)
  {
    //system("rm -f wd.result");
    sleep(10);
    system("ps -e|grep client_user > wd.result");
    checkIfProcess();
  }
}